// 家庭媒体管理系统 - 交互动效库

// ================================
// 动画变量和配置
// ================================

// 动效时间
$animation-instant: 0.1s;
$animation-fast: 0.2s;
$animation-normal: 0.3s;
$animation-slow: 0.5s;
$animation-slower: 0.8s;
$animation-slowest: 1.2s;

// 弹性动效配置
$ease-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
$ease-back-out: cubic-bezier(0.175, 0.885, 0.320, 1.275);
$ease-back-in: cubic-bezier(0.600, -0.28, 0.735, 0.045);
$ease-back-in-out: cubic-bezier(0.680, -0.550, 0.265, 1.550);

// 专业动效曲线
$ease-power1-out: cubic-bezier(0.23, 1, 0.320, 1);
$ease-power2-out: cubic-bezier(0.165, 0.84, 0.44, 1);
$ease-power3-out: cubic-bezier(0.19, 1, 0.22, 1);
$ease-power4-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);

// ================================
// 基础进入动画
// ================================

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-200deg);
  }
  to {
    opacity: 1;
    transform: rotate(0deg);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

// ================================
// 退出动画
// ================================

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes fadeOutUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-30px);
  }
}

@keyframes fadeOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(30px);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.5);
  }
}

// ================================
// 悬停动效
// ================================

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

@keyframes wiggle {
  0%, 7% {
    transform: rotateZ(0);
  }
  15% {
    transform: rotateZ(-15deg);
  }
  20% {
    transform: rotateZ(10deg);
  }
  25% {
    transform: rotateZ(-10deg);
  }
  30% {
    transform: rotateZ(6deg);
  }
  35% {
    transform: rotateZ(-4deg);
  }
  40%, 100% {
    transform: rotateZ(0);
  }
}

// ================================
// 交互反馈动画
// ================================

@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

@keyframes heartbeat {
  0%, 40%, 80%, 100% {
    transform: scale(1);
  }
  20%, 60% {
    transform: scale(1.15);
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translateY(0);
  }
  40%, 43% {
    transform: translateY(-30px);
  }
  70% {
    transform: translateY(-15px);
  }
  90% {
    transform: translateY(-4px);
  }
}

// ================================
// 加载动画
// ================================

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes dots {
  0%, 20% {
    color: transparent;
    text-shadow: 0.25em 0 0 transparent, 0.5em 0 0 transparent;
  }
  40% {
    color: currentColor;
    text-shadow: 0.25em 0 0 transparent, 0.5em 0 0 transparent;
  }
  60% {
    text-shadow: 0.25em 0 0 currentColor, 0.5em 0 0 transparent;
  }
  80%, 100% {
    text-shadow: 0.25em 0 0 currentColor, 0.5em 0 0 currentColor;
  }
}

@keyframes wave {
  0%, 60%, 100% {
    transform: initial;
  }
  30% {
    transform: translateY(-15px);
  }
}

// ================================
// 专项动画 - 媒体相关
// ================================

@keyframes photoReveal {
  0% {
    opacity: 0;
    transform: scale(1.2);
    filter: blur(10px);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

@keyframes cardFlip {
  0% {
    transform: rotateY(0);
  }
  50% {
    transform: rotateY(-90deg);
  }
  100% {
    transform: rotateY(0);
  }
}

@keyframes slideUpReveal {
  0% {
    opacity: 0;
    transform: translateY(50px) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.8), 0 0 30px rgba(59, 130, 246, 0.4);
  }
}

// ================================
// 动效工具类
// ================================

// 基础动效类
.animate-fadeIn {
  animation: fadeIn $animation-normal $ease-out-quart;
}

.animate-fadeInUp {
  animation: fadeInUp $animation-normal $ease-out-quart;
}

.animate-fadeInDown {
  animation: fadeInDown $animation-normal $ease-out-quart;
}

.animate-fadeInLeft {
  animation: fadeInLeft $animation-normal $ease-out-quart;
}

.animate-fadeInRight {
  animation: fadeInRight $animation-normal $ease-out-quart;
}

.animate-scaleIn {
  animation: scaleIn $animation-normal $ease-elastic;
}

.animate-slideInUp {
  animation: slideInUp $animation-normal $ease-power2-out;
}

.animate-slideInDown {
  animation: slideInDown $animation-normal $ease-power2-out;
}

.animate-bounceIn {
  animation: bounceIn $animation-slow $ease-back-out;
}

.animate-rotateIn {
  animation: rotateIn $animation-slow $ease-back-out;
}

// 悬停动效类
.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-bounce {
  animation: bounce 1s infinite;
}

// 交互动效类
.animate-heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

.animate-wiggle {
  animation: wiggle 1s ease-in-out;
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

// 媒体专项动效
.animate-photoReveal {
  animation: photoReveal $animation-slow $ease-power3-out;
}

.animate-slideUpReveal {
  animation: slideUpReveal $animation-normal $ease-power2-out;
}

.animate-glowPulse {
  animation: glowPulse 2s ease-in-out infinite;
}

// ================================
// 悬停动效增强
// ================================

.hover-lift {
  transition: transform $animation-fast $ease-power2-out, box-shadow $animation-fast $ease-power2-out;
  
  &:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: $shadow-lg;
  }
}

.hover-scale {
  transition: transform $animation-fast $ease-elastic;
  
  &:hover {
    transform: scale(1.05);
  }
}

.hover-rotate {
  transition: transform $animation-fast $ease-power2-out;
  
  &:hover {
    transform: rotate(5deg);
  }
}

.hover-glow {
  transition: box-shadow $animation-fast ease-out;
  
  &:hover {
    box-shadow: 0 0 20px rgba($primary-500, 0.4);
  }
}

.hover-float {
  transition: transform $animation-fast $ease-power2-out;
  
  &:hover {
    transform: translateY(-6px);
  }
}

// ================================
// 点击反馈动效
// ================================

.click-scale {
  transition: transform $animation-instant ease-out;
  
  &:active {
    transform: scale(0.95);
  }
}

.click-ripple {
  position: relative;
  overflow: hidden;
  
  &::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width $animation-fast ease-out, height $animation-fast ease-out;
  }
  
  &:active::after {
    width: 300px;
    height: 300px;
  }
}

// ================================
// 页面转场动效
// ================================

.page-enter-active {
  animation: fadeInUp $animation-slow $ease-power3-out;
}

.page-leave-active {
  animation: fadeOutDown $animation-normal $ease-power2-out;
}

// ================================
// 延迟动画工具类
// ================================

.delay-0 { animation-delay: 0s; }
.delay-75 { animation-delay: 0.075s; }
.delay-100 { animation-delay: 0.1s; }
.delay-150 { animation-delay: 0.15s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-500 { animation-delay: 0.5s; }
.delay-700 { animation-delay: 0.7s; }
.delay-1000 { animation-delay: 1s; }

// ================================
// 持续时间工具类
// ================================

.duration-75 { animation-duration: 0.075s; }
.duration-100 { animation-duration: 0.1s; }
.duration-150 { animation-duration: 0.15s; }
.duration-200 { animation-duration: 0.2s; }
.duration-300 { animation-duration: 0.3s; }
.duration-500 { animation-duration: 0.5s; }
.duration-700 { animation-duration: 0.7s; }
.duration-1000 { animation-duration: 1s; }

// ================================
// 响应式动效适配
// ================================

// 在移动设备上减少动效
@include mobile {
  .animate-float,
  .animate-pulse {
    animation: none;
  }
  
  .hover-lift,
  .hover-scale,
  .hover-rotate,
  .hover-glow,
  .hover-float {
    &:hover {
      transform: none;
      box-shadow: none;
    }
  }
}

// 用户偏好适配
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .animate-float,
  .animate-pulse,
  .animate-bounce,
  .animate-heartbeat {
    animation: none !important;
  }
}

// 高性能模式
@media (prefers-reduced-data: reduce) {
  .animate-photoReveal,
  .animate-glowPulse {
    animation: none;
  }
  
  .hover-glow {
    &:hover {
      box-shadow: none;
    }
  }
}

// ================================
// 暗色主题动效适配
// ================================

[data-theme="dark"] {
  .hover-glow {
    &:hover {
      box-shadow: 0 0 20px rgba($primary-400, 0.6);
    }
  }
  
  .animate-glowPulse {
    animation-name: glowPulseDark;
  }
}

@keyframes glowPulseDark {
  0%, 100% {
    box-shadow: 0 0 5px rgba(99, 102, 241, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.6), 0 0 30px rgba(99, 102, 241, 0.3);
  }
}